package 数组;

public class moveZeros {
    public static void moveZeroes(int[] nums) {
        int n=nums.length;
        int left=0,right=1;
        while (right<n){
            if(nums[left]==0){
                while (right<n && nums[right]==0){
                    ++right;
                }
                swap(left,right,nums);
            } else {
                ++right;
            }
            ++left;
        }
    }
    public static void swap(int i,int j,int[] nums){
        int temp=nums[i];
        nums[i]=nums[j];
        nums[j]=temp;
    }

    public static void main(String[] args) {
        moveZeroes(new int[]{0,1,0,3,12});
    }

}
